package ex03;

import java.util.Hashtable;

/**
 * @packgeName: ex03
 * @ClassName: StringManager
 * @copyright: CopyLeft
 * @description:<描述>
 * @author: lili
 * @date: 2017/8/11-15:54
 * @version: 1.0
 * @since: JDK 1.8
 */
public class MyStringManager {

    //flyweight and singleton pattern

    private String packageName;
    private MyStringManager(){}

    private static Hashtable managers = new Hashtable();

    private MyStringManager(String packageName) {
        this.packageName = packageName;
    }


    public synchronized static MyStringManager getManager(String packageName){
        MyStringManager manager = (MyStringManager) managers.get(packageName);
        if(manager == null){
            manager = new MyStringManager(packageName);
            managers.put(packageName,manager);
        }
        return manager;
    }
}
